<template>
	<div class="boxmain">
		<h3 class="titlelist">
			小题分信息
			<div>
				<i v-if="titlecontent.createType==0" @click="importdownload">导入模板</i>
				<p class="uploadImages1" v-if="titlecontent.createType==0">
					<span>批量导入</span>
					<input type="file" @change="changeImg">
				</p>
				<i @click="modifypl">批量修改</i>
				<i style="color:red;" @click="batchDelete">批量删除</i>
			</div>
		</h3> 
		<div class="chooseschool">
			<div>
				选择查看学校
				<el-select v-model="gradeId" placeholder="全部" @change="smallquestionschool">
					<el-option
					  key="全部"
					  label="全部"
					  value="全部">
					</el-option>
				  <el-option
				    v-for="item in schoolList"
				    :key="item.gradeId"
				    :label="item.schoolName"
				    :value="item.gradeId">
				  </el-option>
				</el-select>
			</div>
			<div>
				查找准考证号
				<el-input v-model="zkzh" placeholder="准考证号"></el-input>
				<b class='el-icon-search' @click="zkzhclick"></b>
			</div>
			<div>
				查找姓名
				<el-input v-model="studentName" placeholder="学生姓名"></el-input>
				<b class='el-icon-search' @click="zkzhclick"></b>
			</div>
			<div style="margin-top:20px;">
				查看学科&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<el-select v-model="xkschool" placeholder="全部" @change="smallquestionsubject">
				  <el-option
				    v-for="item in xuekelist"
				    :key="item.id"
				    :label="item.name"
				    :value="item.id">
				  </el-option>
				</el-select>
			</div>
		</div>
		<!-- {{smallquestionlist.length}} -->
		<div class="table-container" ref="scrollContainer" v-if="subjectsmalllist!=null" :style="{height:tableheight+'px'}">
			<table :style="{width:parseInt(smallquestionlist[0].contentScoreInfo.length*110)+'px'}">
				<thead>
					<tr>
						<th width="50">
							 <input type="checkbox" v-model="selectAll" @change="toggleSelectAll">
						</th>
						<th width="120">准考证号</th>
						<th width="140">姓名</th>
						<th width="300">学校</th>
						<th width="100">班级</th>
						<th width="100">总分</th>
						<th width="100">客观题</th>
						<th width="100">主观题</th>
						<th width="80" v-for="item in questionNumber">{{item}}</th>
						<th class="sticky-col" style="padding:0;overflow: hidden;padding-left:2px;">
							<div class="boxdivposition" style="position:relative;z-index:1000;width:100%;padding:10px;box-shadow: -2px 0px 0px rgba(0,0,0,0.1);">
								操作
							</div>
						</th>
					</tr>
				</thead>
				<tbody>
					<tr v-for="item in smallquestionlist">
						<td style="width:40px;">
							<input type="checkbox" v-model="selectedItems" :value="item.itemCase2Id">
						</td>
						<td>{{item.userNumber?item.userNumber:item.examNumber}}</td>
						<td>{{item.studentName}}</td>
						<td>{{item.school}}</td>
						<td>{{item.className}}</td>
						<td>{{item.score}}</td>
						<td>{{item.objScore}}</td>
						<td>{{item.subScore}}</td>
						<td v-for="subject in item.contentScoreInfo">{{subject.score}}</td>
						<td class="sticky-col" style="padding:0;padding-left:2px;">
							<div :class="titlecontent.createType==0?'width160':'width100'" style="height:100%;">
								<span @click="lookcard(item.examNumber)" v-if="item.type==0">答题卡</span>
								<span @click="fixedchengji(item)">修改</span>
								<span @click="deletcard(item.itemCase2Id)">删除</span>
							</div>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
		<div v-else class="emptyBox">
			<p>
				<img src="../../../assets/image/empty.png" alt="">
				<span>抱歉，当前栏目下没有内容！</span>
			</p>
		</div>
		<div v-if="subjectsmalllist!=null" class="boxpagelist">
			<span class="colorGray">已选中{{selectedItems.length}}条，</span>
			<span class="colorGray">共{{listTotal}}条数据</span>
			<el-pagination
			      @size-change="handleSizeChange"
			      @current-change="handleCurrentChange"
			      :current-page="pageIndex"
			      :page-sizes="[20, 50, 100]"
			      :page-size="pageSize"
			      layout="total, sizes, prev, pager, next, jumper"
				  background
			      :total="listTotal?listTotal:0">
			    </el-pagination>
		</div>
		
		<!-- <el-table
			:data="smallquestionlist"
			:height="tableheight"
			border
			 :row-class-name="tableRowClassName"
			  @selection-change="handleSelectionChange"
			 style="width: 100%">
			 <el-table-column
			       type="selection"
			       width="55">
			 </el-table-column>
			 <el-table-column
			   label="总分"
			   prop="score"
			   width="100">
			 </el-table-column>
			 <el-table-column
			   label="客观题"
			   prop="objScore"
			   width="100">
			 </el-table-column>
			 <el-table-column
			   label="主观题"
			   prop="subScore"
			   width="100">
			 </el-table-column>
			<el-table-column
			  v-for="subject in item.contentScoreInfo"
			  :label="questionNum.questionNum" 
			  :prop="subject.score"
			  :key="column.score"
			  width="180">
			</el-table-column>
			<el-table-column
			  label="操作"
			  fixed="right">
			  <template slot-scope="scope">
				  <el-button @click="lookcard(scope.row)" type="text" size="small">答题卡</el-button>
				  <el-button @click="fixedchengji(scope.row)" type="text" size="small">修改</el-button> 
				  <el-button @click="deletcard(scope.row)" type="text" size="small">删除</el-button> 
				</template>
			</el-table-column>
		</el-table>  --> 
		<!-- 修改单人小题分信息 -->
		<div class="batchModifyMain" v-if="modyifyplIshow">
			<div class="batchModifyContent1">
				<h3>修改单人小题分信息</h3>
				<div class="modifyThreetab" style="width:152px">
					<p :class="modifytab==1?'hover':''" @click="schoolmodify(1)">单题修改</p>
					<p :class="modifytab==2?'hover':''" @click="schoolmodify(2)">批量修改</p>
				</div>
				<div>
					<ul>
						<li>
							<span>总分</span>
							<el-input v-model="allscore" disabled placeholder="请输入内容"></el-input>
						</li>
						<li>
							<span>客观题</span>
							<el-input v-model="kgquestion" disabled placeholder="请输入内容"></el-input>
						</li>
						<li>
							<span>主观题</span>
							<el-input v-model="zgquestion" disabled placeholder="请输入内容"></el-input>
						</li>
						<li v-if="modifytab==2">
							<span>题号</span>
							<el-input v-model="smallquetionNumber" @input="smallquetionNumber = $event.replace(/[^0-9#\.]/g, '')" type="textarea" placeholder="输入多个题号以#分隔"></el-input>
						</li>
						<li v-if="modifytab==2">
							<span>批量操作</span>
							<el-input v-model="smallquestionScore" @input="smallquestionScore = $event.replace(/[^0-9+\-*/\.]/g, '')" placeholder="请填写符号加数字"></el-input>
						</li>
						<template v-if="modifytab==1">
							<li v-for="item in modifyquestionNumber">
								<span>{{item.questionNum}}</span>
								<el-input v-model="item.score" @input="item.score = $event.replace(/[^0-9+\-*/\.]/g, '')" placeholder="请输入内容"></el-input>
							</li>
						</template>
					</ul> 
					<div class="groupbutton">
						<el-button type="primary" @click="sureModify">保存</el-button>
						<el-button type="primary"  @click="modifycj">返回</el-button> 
					</div>
				</div>
			</div>
		</div>
		<!-- 批量修改小题分 -->
		<div class="batchModifyMain" v-if="modyifyplanswerIshow"> 
			<div class="batchModifyContent">
				<h3>批量修改</h3>
				<div class="modifyThreetab">
					<p :class="modifytabanswer==1?'hover':''" @click="schoolmodifyanswer(1)">指定范围修改</p>
					<p :class="modifytabanswer==2?'hover':''" @click="schoolmodifyanswer(2)">固定范围修改</p>
				</div>
				<div>
					<ul>
						<!-- modifytab!=2&& -->
						<li v-if="modifytabanswer==2">
							<span>修改范围</span>
							<el-select v-model="jbtype" placeholder="请选择" @change="modifyfanwei">
							  <el-option
							    v-for="item in jibielist"
							    :key="item.id"
							    :label="item.name"
							    :value="item.id">
							  </el-option>
							</el-select>
						</li> 
						<li v-if="jbtype==2&&modifytabanswer==2">
							<span>学校名称</span>
							<el-select v-model="schoolName" multiple placeholder="请选择">
							  <el-option
							    v-for="item in schoolList"
							    :key="item.gradeId"
							    :label="item.schoolName"
							    :value="item.gradeId">
							  </el-option>
							</el-select>
						</li>
						<li v-if="jbtype==3&&modifytabanswer==2">
							<span>学校名称</span>
							<el-select v-model="schoolNameId" placeholder="请选择"  @change="getschoolclass">
							  <el-option
							    v-for="item in schoolList"
							    :key="item.gradeId"
							    :label="item.schoolName"
							    :value="item.gradeId">
							  </el-option>
							</el-select>
						</li>
						<li v-if="jbtype==3&&modifytabanswer==2">
							<span>班级名称</span>
							<el-select v-model="className" multiple placeholder="请选择" @focus="classIf">
							  <el-option
							    v-for="item in classDate"
							    :key="item.id"
							    :label="item.name"
							    :value="item.id">
							  </el-option>
							</el-select>
						</li>
						<li v-if="modifytabanswer===1">
							<span>准考证号</span>
							<el-input v-model="studentExam" type="textarea" @input="studentExam = $event.replace(/[^0-9#\.]/g, '')" placeholder="输入多个准考证号以#分隔"></el-input>
						</li>
						<li>
							<span>修改科目</span>
							<el-select v-model="smallquestionsubjectId" placeholder="请选择">
							  <el-option
							    v-for="item in xuekelist"
							    :key="item.id"
							    :label="item.name"
							    :value="item.id">
							  </el-option>
							</el-select>
						</li>
						<li>
							<span>修改题号</span>
							<el-input v-model="smallquetiontihao" @input="smallquetiontihao = $event.replace(/[^0-9]/g, '')" placeholder="请输入内容"></el-input>
						</li>
						<li>
							<span>批量操作</span>
							<el-input v-model="smallquestionscoreadd" @input="smallquestionscoreadd = $event.replace(/[^0-9+\-*/\.]/g, '')" placeholder="请填写符号加数字 "></el-input>
						</li>
					</ul> 
					<div class="groupbutton">
						<el-button type="primary" @click="modifyplsure">保存</el-button>
						<el-button type="primary" @click="modifyplback">返回</el-button> 
					</div>
				</div>
			</div>
		</div> 
		<!-- 答题卡 -->
		<div class="missanexam" v-if="cardexamIshow">
			<h3><i class="el-icon-warning-outline"></i>请选择查看答题卡科目</h3>
			<el-radio-group v-model="cardradio">
			    <el-radio v-for="item in xuekelist" :label="item.id" :key="item.id" >{{item.name}}</el-radio>
			</el-radio-group>
		  <div class="boxbutton">
			  <el-button type="primary" @click="cardlooksure">确定</el-button>
			  <el-button type="info" @click="cardexamIshow=false">取消</el-button> 
		  </div>
		</div>
	</div>
</template>

<script>
	import {
		analysisClassSmallQuestionScore,
		navgetgrade,
		groupExamList,
		importdownloadsmall,
		smallquestionimport,
		lookcardlist,
		smallquestionupdate,
		groupcalssList,
		studentsmallquestionDelete
	} from '../../../api/scoreapi.js'
	export default{
		data(){
			return{
				gradeId:'全部',
				jibielist:[
					{id:4,name:'联考'},
					{id:2,name:'校级'},
					{id:3,name:'班级'}
				],
				jbtype:4,
				schoolNameId:'',
				className:'',
				schoolName:'',
				searchschool:'全部',
				cardexamIshow:false,
				tableData: [],
				tableheight:'',
				fixedchengjiIshow:false,
				studentinfo:{
					xuehao:'',
					zhunkaozhenghao:'',
					name:'',
					xuanke1:'',
					xuanke2:'',
					xuanke4:'',
					xiaoyuzhong:''
				},
				checkList:[],
				modifytab:1,
				modyifyplIshow:false,
				modyifyplanswerIshow:false,
				modifytabanswer:1,
				multipleSelection:[],
				xuekelist:[],
				schoolList:[],
				xkschool:'',
				subjectsmalllist:[],
				columns: [],
				questionNumber:[],
				smallquestionlist:[],
				selectedItems: [],
				pageIndex:1,
				pageSize:20,
				listTotal:0,
				 titlecontent:{},
				 zkzh:'',
				 studentName:'',
				 lookcardlist:[],
				 cardradio:'',
				 modifyquestionNumber:[],
				 allscore:'',
				 kgquestion:'',
				 zgquestion:'',
				 smallquetionNumber:'',
				 smallquestionScore:'',
				 classDate:[],
				 smallquestionsubjectId:'',
				 smallquetiontihao:'',
				 smallquestionscoreadd:'',
				 studentExam:'',
				 modifysmallquetionscore:{
					type:'', //修改类型 0单个修改 1准考证号修改 2班级修改 3校级修改 4联考修改
					id:'', //从小题分列表获取，单个修改时传值
					subjectId:'', //学科id
					questionScoreList:[
						{
							questionNum:'', //单题修改
							questionNums:"", //批量修改
							score:'',//分数
							questionType:'',//0主观题1客观题
							type:'' //1加2减3乘4除
						}
					]
				 },
				 currentPagetotal:20
			}
		},
		mounted() {
			this.getScreenHeight();
			//在窗口大小变化时更新屏幕高度，可以监听window的resize事件
			window.addEventListener('resize', this.getScreenHeight);
			let newtitle = decodeURIComponent(this.$route.query.con)
			this.titlecontent = JSON.parse(newtitle)
			this.getSchoolList()
			this.$refs.scrollContainer.addEventListener('scroll', this.handleScroll);
			localStorage.setItem('menuState', 2);
		},
		methods: {
			// 批量导入成绩
			changeImg(e){
				const files = e.target.files;
				if (files.length === 0) {
					// 没有选择文件，用户可能点击了取消
					return;
				}
				let params={
					navId:this.titlecontent.n5Id,
					file:e.target.files[0]
				}
				smallquestionimport(params).then(res=>{
					this.$message({
						type: 'success',
						message: res.msg
					}); 
					this.smallquetionscore(this.xkschool)
					this.getSchoolList()
				})
			},
			//获取学科列表
			xuekeclick(areaid){
				let params={
					ntype:6,
					id:areaid
				}
				navgetgrade(params).then(res=>{
					if(res.code==0){
						this.xuekelist = res.data
						this.xkschool = res.data[0].id
						this.smallquetionscore(res.data[0].id)
					}else{
						this.$message({
							type: 'error',
							message: res.msg
						}); 
					}
				})
			},
			// xuekeclick(areaid){
			// 	let params={
			// 		ntype:6,
			// 		id:areaid
			// 	}
			// 	navgetgrade(params).then(res=>{
			// 		if(res.code==0){
			// 			this.xuekelist = res.data
			// 		}else{
			// 			this.$message({
			// 				type: 'error',
			// 				message: res.msg
			// 			}); 
			// 		}
			// 	})
			// },
			lookcard(examNumber){
				this.xszkzh= examNumber
				let params={
					navId:this.xkschool,
					stuNameOrExamNo:examNumber
				}
				lookcardlist(params).then(res=>{
					console.info(res)
					if(res.code==0){
						if(res.data.length<=0){
							this.$message({
								type: 'error',
								message: '该学生没有答题卡'
							}); 
							this.cardexamIshow = false
						}else{
							let photo=[]
							if(res.data[0].cardfront2!=null){
								photo.push(this.$imgUrl1+res.data[0].cardfront2)
							}else{
								photo.push(this.$imgUrl3+res.data[0].cardfront)
							}
							if(res.data[0].cardreverse2!=null){
								photo.push(this.$imgUrl1+res.data[0].cardreverse2)
							}else{
								photo.push(this.$imgUrl3+res.data[0].cardreverse)
							}
							const $viewer = this.$viewerApi({
								images: photo
							})
							this.cardexamIshow = false
						}
					}else{
						this.$message({
							type: 'error',
							message: res.msg
						}); 
					}
				})
			},
			//选择查看答题卡
			// cardlooksure(){
			// 	let params={
			// 		navId:this.cardradio,
			// 		stuNameOrExamNo:this.xszkzh
			// 	}
			// 	lookcardlist(params).then(res=>{
			// 		console.info(res)
			// 		if(res.code==0){
			// 			if(res.data.length<=0){
			// 				this.$message({
			// 					type: 'error',
			// 					message: '该学生没有答题卡'
			// 				}); 
			// 				this.cardexamIshow = false
			// 			}else{
			// 				let photo=[]
			// 				photo.push(res.data[0].cardfront)
			// 				photo.push(res.data[0].cardreverse)
			// 				const $viewer = this.$viewerApi({
			// 					images: photo
			// 				})
			// 				this.cardexamIshow = false
			// 			}
			// 		}else{
			// 			this.$message({
			// 				type: 'error',
			// 				message: res.msg
			// 			}); 
			// 		}
			// 	})
			// },
		    getScreenHeight() {
		      // 获取屏幕高度并更新data中的screenHeight
		      this.tableheight = parseInt(window.innerHeight-410);
		    },
			//修改单人小题分信息
			fixedchengji(con){
				this.modifysmallquetionscore.id=con.itemCase2Id
				this.allscore=con.score
				this.zgquestion = con.subScore
				this.kgquestion = con.objScore
				this.modyifyplIshow=true
			},
			//table各色换行
			tableRowClassName({row, rowIndex}) {
				return rowIndex % 2 === 0 ? 'warning-row' : 'success-row'
			},
			//tab切换
			schoolmodify(num){
				this.modifytab = num
			},
			schoolmodifyanswer(num){
				this.modifytabanswer = num
				this.schoolName=''
				this.schoolNameId=''
				this.className=''
				this.smallquestionsubjectId=''
				this.studentExam=''
				this.className=''
				this.schoolName=[]
				this.smallquetiontihao=''
				this.smallquestionscoreadd=''
			},
			//批量修改
			modifypl(){
				this.modyifyplanswerIshow= true
			},
			handleSelectionChange(val) {
				this.multipleSelection = val;
			},
			// 处理每页条数变化
			handleSizeChange(val){
				this.pageSize = val
				 this.smallquetionscore(this.xkschool)
			},
			// 处理当前页码变化
			handleCurrentChange(val){
				this.pageIndex = val
				 this.smallquetionscore(this.xkschool)
			},
			// calculateIsLastPage() {
			//   const lastPage = Math.ceil(this.listTotal / this.pageSize);
			//   const isLastPage = this.pageIndex === lastPage;
			//   this.smallquetionscore(this.xkschool)
			//   if(isLastPage){
			// 	  this.currentPagetotal = this.listTotal
			//   }else{
			// 	 this.currentPagetotal = this.pageSize*this.pageIndex
			//   }
			//   // 根据isLastPage的值做相应处理
			// },
			//获取小题分列表
			smallquetionscore(xkid){
				this.isLoading = true;
				let params={
					navId:xkid,
					groupId:this.gradeId=='全部'||this.gradeId==''?undefined:this.gradeId,
					groupType:2,
					stuNameOrExamNo: this.zkzh?this.zkzh:undefined,
					studentName:this.studentName?this.studentName:undefined,
					pageIndex:this.pageIndex,
					pageSize:this.pageSize
				}
				analysisClassSmallQuestionScore(params).then(res=>{
					if(res.code==0){
							this.subjectsmalllist = res.data
							if(res.data.length<=0){
							   this.selectAll = !this.selectAll
							   this.listTotal=0
							   this.pageIndex=1
							   // console.info(this.selectAll)
							   return false
							}
							// 提取objScoreInfo中的questionNum
							  const objQuestionNums = res.data[0].objScoreInfo.map(obj => obj.questionNum);
							  // 提取subScoreInfo中的questionNum
							  const subQuestionNums = res.data[0].subScoreInfo.map(sub => sub.questionNum);
							  // 合并两个数组并添加到累加器中
							  // return object.concat(objQuestionNums, subQuestionNums);
							// 如果需要去除重复的questionNum，可以使用Set
							// const uniqueNumber = [...new Set(number)];
							const mergedArray = [...objQuestionNums, ...subQuestionNums];
							mergedArray.sort((a, b) => a - b);
							this.questionNumber = mergedArray
							// 提取objScoreInfo中的questionNum
							  const objQuestionNums1 = res.data[0].objScoreInfo.map(obj => obj);
							  // 提取subScoreInfo中的questionNum
							  const subQuestionNums1 = res.data[0].subScoreInfo.map(sub => sub);
							  this.modifyquestionNumber = [...objQuestionNums1, ...subQuestionNums1]
							  console.info(this.modifyquestionNumber)
							const box= this.subjectsmalllist.map(item => {
							  return {
							    ...item, // 展开原对象以保留其他属性
							    contentScoreInfo: [ // 创建新的 contentScoreInfo 数组
							      ...item.objScoreInfo, // 展开 objScoreInfo 数组
							      ...item.subScoreInfo // 展开 subScoreInfo 数组
							    ]
							  };
							});
							box.map(item=>{
								item.contentScoreInfo.sort((a, b) => a.questionNum - b.questionNum)
							})
							this.smallquestionlist = box
							if(this.pageIndex==1){
								   this.listTotal = res.data[0].total
								   sessionStorage.setItem('total',res.data[0].total)
							}else{
								this.listTotal = Number(sessionStorage.getItem('total'))
							}      
					}else{
						this.$message.error(res.msg);
					}
				})
			},
			//获取学校列表
			getSchoolList() {
			  groupExamList({navId: this.titlecontent.n5Id}).then(res => {
			    this.schoolList = res.data
				// this.gradeId = res.data[0].gradeId
				this.xuekeclick(JSON.parse(this.$route.query.con).n5Id)
			  })
			},
			// 切换全选状态
			    toggleSelectAll() {
					console.info()
			      if (this.selectAll) {
					// 如果全选，则将所有项的ID添加到selectedIds中
					this.selectedIds = this.smallquestionlist.map(item => item.itemCase2Id);
					// console.info(this.selectedIds)
			      } else {
			        // 如果取消全选，则清空selectedIds
			        this.selectedIds = [];
			      }
			    },
			removeItem(index) {
			  // 删除项目
			  this.smallquestionlist.splice(index, 1);
			  // 更新选中的项目数组
			  this.selectedItems = this.selectedItems.filter(id => {
				return this.smallquestionlist.some(item => item.itemCase2Id === id);
			  });
			},
			deleteSelectedItems() {
			  // 删除选中的项目
			  this.smallquestionlist = this.smallquestionlist.filter(item => !this.selectedItems.includes(item.itemCase2Id));
			  // 清空选中的项目数组
			  this.selectedItems = [];
			  // 取消全选状态
			   this.selectAll = false;
			},
			//下载小题分模板
			importdownload(){
				let params={
					navId:this.titlecontent.n5Id
				}
				importdownloadsmall(params).then(res=>{
					console.info(res)
					if(res.code==0){
						const a = document.createElement('a');
						// 设置下载链接和文件名
						a.href = res.msg
						a.download = '导入成绩模板'
						// 模拟点击事件以触发下载
						a.click();
						// 清理：移除创建的<a>元素
						document.body.removeChild(a);
					}else{
						this.$message({
							type: 'error',
							message: res.msg
						}); 
					}
					
				})
			},
			//切换学科从新调内容
			smallquestionsubject(val){
				this.subjectsmalllist =[]
				this.pageIndex=1
				this.smallquetionscore(val);
			},
			// 切换学校
			smallquestionschool(val){
				this.subjectsmalllist =[]
				this.pageIndex=1
				this.gradeId = val=='全部'||val==''?undefined:val
				this.smallquetionscore(this.xkschool);
			},
			zkzhclick(){
				this.subjectsmalllist=[]
				this.pageIndex=1
				this.smallquetionscore(this.xkschool)
			},
			//返回
			modifycj(){
				// this.studentinfo=[]
				this.modyifyplIshow=false
				this.modifytabanswer = 1
				this.modifysmallquetionscore={
					type:'', //修改类型 0单个修改 1准考证号修改 2班级修改 3校级修改 4联考修改
					id:'', //从小题分列表获取，单个修改时传值
					subjectId:'', //学科id
					questionScoreList:[
						{
							questionNum:'', //单题修改
							questionNums:"", //批量修改
							score:'',//分数
							questionType:'',//0主观题1客观题
							type:'' //1加2减3乘4除
						}
					]
				}
			},
			determineSign(value) {
				  const firstChar = value.charAt(0); // 获取字符串的第一个字符
				  switch (firstChar) {
					case '+':
					  return '加号';
					case '-':
					  return '减号';
					case '*':
					  return '乘号';
					case '/':
					  return '除号';
					default:
					  return '未知符号';
				  }
				},
				determineSign1(fhao) {
				  switch (fhao) {
					case '加号':
					  return 1;
					case '减号':
					  return 2;
					case '乘号':
					  return 3;
					case '除号':
					  return 4;
					default:
					  return undefined;
				  }
				},
			//保存单个科目单个小题修改成绩
			sureModify(){
				// this.studentinfo.updateType = 1
				if(this.modifytab==1){
					let filteredList = this.modifyquestionNumber.map(item => ({
					  questionNum: item.questionNum,
					  score: item.score,
					  questionType:item.order==2?0:1
					}));
					this.modifysmallquetionscore.questionScoreList = filteredList
				}else{
					let fhao = this.determineSign(this.smallquestionScore)
					this.modifysmallquetionscore.questionScoreList[0].questionNums = this.smallquetionNumber
					this.modifysmallquetionscore.questionScoreList[0].score = this.smallquestionScore.substring(1)
					this.modifysmallquetionscore.questionScoreList[0].type=this.determineSign1(fhao)
					this.modifysmallquetionscore.questionScoreList[0].questionNum = undefined
					this.modifysmallquetionscore.questionScoreList[0].questionType = undefined
				}
				this.modifysmallquetionscore.type = 0
				this.modifysmallquetionscore.subjectId = this.xkschool
				console.info(this.modifysmallquetionscore)
				smallquestionupdate(this.modifysmallquetionscore).then(res=>{
					if(res.code==0){
						this.pageIndex = 1
						this.subjectsmalllist = []
						this.modifysmallquetionscore={
							type:'', //修改类型 0单个修改 1准考证号修改 2班级修改 3校级修改 4联考修改
							id:'', //从小题分列表获取，单个修改时传值
							subjectId:'', //学科id
							questionScoreList:[
								{
									questionNum:'', //单题修改
									questionNums:"", //批量修改
									score:'',//分数
									questionType:'',//0主观题1客观题
									type:'' //1加2减3乘4除
								}
							]
						}
						this.$message({
							type: 'success',
							message: '修改成功'
						}); 
						this.smallquetionscore(this.xkschool);
						this.modyifyplIshow=false
					}else{
						this.$message({
							type: 'error',
							message: res.msg
						}); 
					}
				})
			},
			// 获取班级列表
			getclassList(gradeid){
				let params={
					id:gradeid
				}
				groupcalssList(params).then(res=>{
					if(res.code==0){
						console.info(res)
						this.classDate=res.data
					}else{
						this.$message({
							type: 'error',
							message: res.msg
						});
					}
				})
			},
			//点击学校下拉获取年纪$("#")
			getschoolclass(val){
				// this.modifystudentinfo.batchStudentScore.gradeId = [val]
				this.getclassList(val)
				this.schoolName = [val]
			},
			//点击班级下拉判断校级是否选择否则提示
			classIf(){
				if(this.schoolNameId==''){
					this.$message({
						type: 'error',
						message: '请先选择校级列表'
					});
				}
			},
			// 返回
			modifyplback(){
				this.modyifyplanswerIshow=false
			},
			//批量保存
			modifyplsure(){
				if(this.modifytabanswer ==1){
					this.modifysmallquetionscore.type=1
				}else{
					this.modifysmallquetionscore.type = this.jbtype
				}
				let fhao = this.determineSign(this.smallquestionscoreadd)
				this.modifysmallquetionscore.id = undefined
				this.modifysmallquetionscore.subjectId=this.smallquestionsubjectId
				this.modifysmallquetionscore.userNumber = this.studentExam?this.studentExam:undefined
				this.modifysmallquetionscore.classId = this.className?this.className:undefined
				this.modifysmallquetionscore.gradeId =  this.schoolName.length>0?this.schoolName:undefined
				this.modifysmallquetionscore.questionScoreList[0].questionNum = this.smallquetiontihao?this.smallquetiontihao:undefined,
				this.modifysmallquetionscore.questionScoreList[0].score = this.smallquestionscoreadd.substring(1)
				this.modifysmallquetionscore.questionScoreList[0].type=this.determineSign1(fhao)
				this.modifysmallquetionscore.questionScoreList[0].questionNums=undefined
				this.modifysmallquetionscore.questionScoreList[0].questionType=undefined
				console.info(this.modifysmallquetionscore)
				smallquestionupdate(this.modifysmallquetionscore).then(res=>{
					if(res.code==0){
						this.pageIndex = 1
						this.subjectsmalllist = []
						this.modifysmallquetionscore={
							type:'', //修改类型 0单个修改 1准考证号修改 2班级修改 3校级修改 4联考修改
							id:'', //从小题分列表获取，单个修改时传值
							subjectId:'', //学科id
							questionScoreList:[
								{
									questionNum:'', //单题修改
									questionNums:"", //批量修改
									score:'',//分数
									questionType:'',//0主观题1客观题
									type:'' //1加2减3乘4除
								}
							]
						}
						this.schoolName=''
						this.schoolNameId=''
						this.className=''
						this.smallquestionsubjectId=''
						this.studentExam=''
						this.className=''
						this.schoolName=[]
						this.smallquetiontihao=''
						this.smallquestionscoreadd=''
						this.$message({
							type: 'success',
							message: '修改成功'
						}); 
						this.smallquetionscore(this.xkschool);
						this.modyifyplanswerIshow=false
					}else{
						this.$message({
							type: 'error',
							message: res.msg
						}); 
					}
				})
				// this.modifysmallquetionscore.questionScoreList[0],
			},
			modifyfanwei(){
				this.schoolName=''
				this.schoolNameId=''
				this.className=''
				this.smallquestionsubjectId=''
				this.studentExam=''
				this.className=''
				this.schoolName=[]
				this.smallquetiontihao=''
				this.smallquestionscoreadd=''
			},
			//删除成绩deletcard
			deletcard(id){
				let params={
					ids:[id]
				}
				this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
				  confirmButtonText: '确定',
				  cancelButtonText: '取消',
				  type: 'warning'
				}).then(() => {
					studentsmallquestionDelete(params).then(res=>{
						if(res.code==0){
							this.subjectsmalllist = []
							this.zkzh = ''
							this.smallquetionscore(this.xkschool);
							this.$message({
								type: 'success',
								message: '删除成功!'
							});
						}else{
							this.$message({
								type: 'error',
								message: res.msg
							});
						}
					})
				  
				}).catch(() => {
				  this.$message({
					type: 'info',
					message: '已取消删除'
				  });          
				});
			},
			// 批量删除
			batchDelete(){
				let params={
					ids:this.selectedItems
				}
				this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
				  confirmButtonText: '确定',
				  cancelButtonText: '取消',
				  type: 'warning'
				}).then(() => {
					studentsmallquestionDelete(params).then(res=>{
						if(res.code==0){
							this.selectAll =false
							this.smallquetionscore(this.xkschool);
							this.$message({
								type: 'success',
								message: '删除成功!'
							});
						}else{
							this.$message({
								type: 'error',
								message: res.msg
							});
						}
					})
				  
				}).catch(() => {
				  this.$message({
					type: 'info',
					message: '已取消删除'
				  });          
				});
			},
		},
		computed: {
			selectAll: {
				get: function () {
					return this.smallquestionlist.length === this.selectedItems.length;
				},
				set: function (value) {
					if (value) {
					  // 选中所有
					  this.selectedItems = this.smallquestionlist.map(item => item.itemCase2Id);
					} else {
					  // 取消选中
					  this.selectedItems = [];
					}
				}
			}
		},
		beforeDestroy() {
			// 在组件销毁前移除事件监听器，避免内存泄漏
			window.removeEventListener('resize', this.getScreenHeight);
			this.$refs.scrollContainer.removeEventListener('scroll', this.handleScroll)
		},
	}
</script>

<style scoped>
	.titlelist{
		padding:0 0 20px;
		font-size:18px;
		display: flex;
		justify-content: space-between;
	}
	.titlelist>>> .el-button{
		background:#165DFF
	}
	.titlelist div{
		 font-size:14px;
		 color:#1664FF;
		 font-style: normal;
		 font-weight: normal;
		 display: flex;
		 align-items: center;
	}
	.titlelist div i{
		display: inline-block;
		margin-left:20px;
		cursor: pointer;
		font-style:normal
	}
	.titlelist div p{
		margin-left:20px;
	}
	.boxmain{
		box-sizing: border-box;
		padding:30px 30px 0;
	}
	.addstudent{
		display: flex;
		justify-content: space-between;
		padding-bottom:15px;
		font-size:18px;
		font-weight:bold;
	}
	.addstudent b{
		font-weight:normal;
		color:#1664FF;
		cursor: pointer;
		font-size:14px;   
	}
	.chooseschool{
		margin-bottom:15px;
		display: flex;
		align-items: center;
		flex-wrap: wrap;
	}
	.chooseschool >>> .el-select{
		margin-left:10px;
	}
	.addExamMain,.batchModifyMain{
		position: fixed;
		width:100%;
		height:100%;
		background:rgba(0,0,0,0.5);
		left:0;
		top:0;
		z-index:1100;
	}
	.addExamContent{
		width: 600px;
		height: 700px;
		position: fixed;
		background:#fff;
		left:50%;
		top:50%;
		transform: translate(-50%,-50%);
		z-index:101;
		box-sizing: border-box;
		padding:30px;
		overflow-y: auto;
	}
	.batchModifyContent{
		width: 600px;
		min-height: 500px;
		position: fixed;
		background:#fff;
		left:50%;
		top:50%;
		transform: translate(-50%,-50%);
		z-index:101;
		box-sizing: border-box;
		padding:30px;
		overflow-y: auto;
	}
	.batchModifyContent1{
		width: 600px;
		max-height: 700px;
		position: fixed;
		background:#fff;
		left:50%;
		top:50%;
		transform: translate(-50%,-50%);
		z-index:101;
		box-sizing: border-box;
		padding:30px;
		overflow-y: auto;
	}
	.addExamContent h3{
		font-size:18px;
		padding:10px 0 30px;
	}
	.addExamContent ul li{
		display: flex;
		align-items: center;
		padding-bottom:15px;
	}
	.addExamContent ul li span{
		font-size:14px;
		display: flex;
		align-items: center;
		width:100px;
		justify-content: left;
	}
	.batchModifyContent ul li span,.batchModifyContent1 ul li span{
		display: inline-block;
		width:100px;
	}
	.batchModifyContent ul li,.batchModifyContent1 ul li{
		display: flex;
		align-items: center;
		margin-bottom:20px;
	}
	.addExamContent ul li span i{
		font-style:normal;
		color:red;
		padding-left:5px;
	}
	.addExamContent ul li p{
		position: relative;
	}
	.addExamContent ul li p em{
		position: absolute;
		right:10px;
		top:50%;
		transform: translateY(-50%);
		color:#C0C4CC;
		cursor: pointer;
	}
	.addExamContent ul li >>> .el-input,.addExamContent ul li >>> .el-textarea{
		width:350px;
	}
	.batchModifyContent ul li >>> .el-input,.batchModifyContent ul li >>> .el-textarea{
		width:260px;
	}
	.batchModifyContent ul li b{
		color:#1664FF;
		cursor: pointer;
		font-size:14px;
	}
	.groupbutton{
		display: flex;
		align-items: center;
		padding-top:30px;
	}
	.groupbutton >>> .el-button{
		background:#165DFF;
		width:100px;
		margin-right:20px;
	}
	.boxmain >>> .el-table .warning-row {
	    background: rgb(243, 247, 255);
	}
	.boxmain >>> .el-table .success-row {
	    background:#fff;
	}
	.boxmain >>> .el-table .el-table__header-wrapper thead th { 
	  background-color:rgb(220, 231, 255); /* 设置你想要的背景颜色 */
	  color: #000000; /* 设置你想要的文字颜色 */
	}
	.boxbutton{
		display: flex;
		justify-content: center;
		padding-top:24px;
	}
	.boxbutton >>> .el-button:last-child{
		margin-left:30px;
	}
	.chooseschool div{
		display: flex;
		align-items: center;
		position:relative;
		margin-right:24px;
	}
	.chooseschool div:last-child{
		margin-right:0;
	}
	.chooseschool div >>> .el-input{
		width:185px;
		margin-left:20px;
	}
	.chooseschool div b{
		position:absolute;
		right:38px;
		top:50%;
		transform: translateY(-50%);
		cursor: pointer;
	}
	.modifyThreetab{
		background:rgb(242, 243, 245);
		width:208px;
		height: 30px;
		display: flex;
		line-height:30px;
		margin:20px 0;
		padding:2px;
	}
	.modifyThreetab p{
		padding:0 10px;
		cursor: pointer;
	}
	.modifyThreetab p:hover,.modifyThreetab p.hover{
		background:#fff;
		color:#0052D9
	}
	.table-container {
	    overflow-y: auto;
	   border:1px solid #EBEEF5; 
	    margin: 20px 0;
	}
	
	.table-container  table {
	    border-collapse: collapse;
	}
	
	.table-container  thead th {
	    position: sticky; /* This makes the header sticky */
	    top: 0; /* Top position of the sticky header */
	    background-color:rgb(220, 231, 255); /* Header background color */
	    border-bottom:1px solid #EBEEF5; /* Bottom border to separate header from body */
	    padding: 10px;
	    text-align: left;
		z-index:1000
	}
	
	.table-container tbody td {
		width:100px;
	    padding: 10px;
	    border-bottom: 1px solid #EBEEF5;
	}
	.table-container tbody tr:nth-child(2n){
		background:rgb(243, 247, 255)
	}
	.table-container tbody td >>> input,.table-container tbody th >>> input{
		border:1px solid #dcdfe6;
	}
	.table-container tbody td div span{
		display:inline-block;
		color:#366EF4;
		margin-right:15px;
		cursor: pointer;
	}
	.table-container tbody td div span:last-child{
		color:#EA0000
	}
	.sticky-col {
	    position: -webkit-sticky; /* Safari */
	    position: sticky;
	    right: 0;
	    background: #fff;
	    z-index: 100; /* Make sure this column stays on top */
		box-shadow:0 0 0 rgba(0,0,0,0.5)
	  }
	  .uploadImages1{
	  	position:relative;
	  	padding-top:0;
	  	cursor: pointer;
	  }
	  .uploadImages1 span{
	  	box-sizing: border-box;
	  	display: block;
	  	width:100%;
	  	background:none;
	  	cursor: pointer;
	  	margin:0 auto;
	  	border-radius:6px;
	  	text-align:center;
	  	font-size:14px;
	  	color:#1664FF;
	  	cursor: pointer;
	  	font-weight: normal;
	  }
	  .uploadImages1 input{
	  	background:none;
	  	position:absolute;
	  	left:50%;
	  	top:0;
	  	opacity: 0;
	  	z-index:2;
	  	color: #000;
	  	cursor: pointer;
	  	height:20px;
	  	transform: translateX(-50%);
	  	width:100%;
	  	cursor: pointer;
	  }
	  .missanexam{
	  	width: 634px;
	  	height: 272px;
	  	border-radius: 4px;
	  	background:#fff;
	  	position:fixed;
	  	left:50%;
	  	top:50%;
	  	transform: translate(-50%,-50%);
	  	box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.3);
	  	z-index:1100;
	  	box-sizing: border-box;
	  	padding:0 30px;
	  }
	  .missanexam h3{
	  	text-align: center;
	  	padding:24px 0;
	  	font-size:14px;
	  	font-weight: normal;
	  }
	  .missanexam h3 i{
	  	font-style:normal;
	  	color:rgb(255, 125, 0);
	  	font-size:16px;
	  	display: inline-block;
	  	padding-right:6px;
	  }
	  .missanexam p{
	  	text-align: center;
	  	font-size:14px;
	  	padding-bottom:24px;
	  }
	  .missanexam >>> .el-radio{
	  	margin-top:30px;
	  }
	  .emptyBox{
	  	position:relative;
		padding-top:100px;
	  }
	  .emptyBox p{
	  	/* position:absolute;
	  	left:50%;
	  	top:40%;
	  	transform:translate(-50%,-50%); */
	  	text-align:center;
	  }
	  .emptyBox p span{
	  	display:block;
	  	padding-top:30px;
	  }
	  .width160{
		  width:160px;
		  padding:10px;
		  box-shadow: -2px 0px 0px rgba(0,0,0,0.1)
	  }
	  .width100{
		  width:100px;
		  padding:10px;
		  box-shadow:-2px 0px 0px rgba(0,0,0,0.1)
	  }
	  .boxpagelist{
	  		  display: flex;
	  		  align-items: center;
	  }
	  .boxpagelist >>> .el-pagination__total{
	  		  display: none !important;
	  }
	  .colorGray{
	  		  font-size:12px;
	  		  color:#999;
	  }
	  .boxpagelist >>> .el-pagination__jump{
	  		  color:#999;
	  		  font-size:12px;
	  }
	  .boxpagelist >>> .el-pagination__sizes .boxpagelist >>> .el-input .boxpagelist >>> .el-input__inner{
	  		  font-size:12px;
	  }
	  .boxpagelist >>> .el-pagination.is-background  .boxpagelist >>> .el-pager li:not(.disabled).active{
	  		 background-color:#1664FF !important
	  }
</style>